package artid.com.arttogoa.adapter;

import java.util.List;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import artid.com.arttogoa.R;
import artid.com.arttogoa.parser.FilesBean;
import com.bumptech.glide.Glide;

public class AlbumAdapter extends BaseAdapter {

	private List<FilesBean> filesList;
	private Context mContext;

	// ImageLoader mImageLoader;

	public AlbumAdapter(Context context, List<FilesBean> filesList) {
		this.filesList = filesList;
		this.mContext = context;
		// RequestQueue mQueue = Volley.newRequestQueue(context);
		// mImageLoader = new ImageLoader(mQueue, new BitmapCache());
	}

	@Override
	public int getCount() {
		return filesList != null ? filesList.size() + 1 : 1;
	}

	@Override
	public Object getItem(int position) {
		return filesList.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@SuppressWarnings("null")
	@SuppressLint("InflateParams")
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder vh = null;
		if (convertView == null) {
			vh = new ViewHolder();
			convertView = LayoutInflater.from(mContext).inflate(
					R.layout.item_grid_main, null);
			vh.iv = (ImageView) convertView.findViewById(R.id.icon);
			convertView.setTag(vh);
		} else {
			vh = (ViewHolder) convertView.getTag();
		}
		if (getCount() == position + 1) {

		}else{
			FilesBean item = null;
			String url = "";
			url = item.getThumbURL();
			// ImageListener listener = ImageLoader.getImageListener(vh.iv,
			// android.R.drawable.ic_menu_rotate,
			// android.R.drawable.ic_delete);
			// mImageLoader.get(url, listener);
			Glide.with(mContext).load(url).placeholder(R.drawable.yspba_img_mor)
					.error(android.R.drawable.ic_delete).into(vh.iv);
		}
		
		return convertView;
	}

	class ViewHolder {
		ImageView iv;
	}
}